View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.geronimo.ews.ws4j2ee.toWs;
18  
19  import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
20  import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
21  
22  /***
23   * abstract class writer
24   *
25   * @author Srianth Perera(hemapani@opensource.lk)
26   */
27  public abstract class JavaInterfaceWriter extends AbstractWriter {
28      protected String qulifiedName;
29      protected String classname;
30      protectedong> String packageName;
31      private String pacakgesatement;
32      private String targetDirectory;
33  
34      public JavaInterfaceWriter(J2EEWebServiceContext j2eewscontext, String qulifiedName) throws GenerationFault {
35          super(j2eewscontext, Utils.getFileNamefromClass(j2eewscontext, qulifiedName));
36          if (qulifiedName == null) {
37              throw new GenerationFault("the class qualified name must not be null");
38          }
39          this.qulifiedName = qulifiedName;
40          packageName = Utils.getPackageNameFromQuallifiedName(qulifiedName);
41          classname = Utils.getClassNameFromQuallifiedName(qulifiedName);
42      }
43  
44      public void writeCode() throws GenerationFault {
45          if (out == null)
46              return;
47          out.write((packageName != null) ? ("package " + packageName + ";\n") : "");
48          writeImportStatements();
49          writeClassComment();
50          out.write("public interface "
51                  + classname
52                  + getExtendsPart()
53                  + "{\n");
54          writeAttributes();
55          writeMethods();
56          out.write("}\n");
57      }
58  
59      protected String getExtendsPart() {
60          return " ";
61      }
62  
63      protected void writeClassComment() throws GenerationFault {
64      }
65  
66      protected void writeImportStatements() throws GenerationFault {
67      }
68  
69      protected abstract void writeAttributes() throws GenerationFault;
70  
71      protected abstract void writeMethods() throws GenerationFault;
72  }